package jsp.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcUtils {

    private final static String DRIVER = "com.mysql.cj.jdbc.Driver";
    private final static String URL = "jdbc:mysql://121.43.154.199:3306/public?serverTimezone=UTC";
    private final static String USERNAME = "public";
    private final static String PASSWORD = "public";

    public static Connection getConnection() throws Exception {
        Class.forName(DRIVER);
        return DriverManager.getConnection(URL, USERNAME, PASSWORD);

    }


    public static void close(ResultSet rs, Statement state, Connection con) throws Exception {

        if (rs != null) {
            rs.close();
        }
        if (state != null) {
            state.close();
        }
        if (con != null) {
            con.close();
        }
    }
}
